package com.ht.medicaltreatment.viewmodel

import androidx.lifecycle.viewModelScope
import com.ht.medicaltreatment.bean.SearchResultBean
import com.xgst.lib.http.ApiResult
import kotlinx.coroutines.launch

class SearchResultViewModel : BaseViewModel() {

    fun search(keywords:String,onSuccess:(MutableList<SearchResultBean>?)->Unit,onError:(String)->Unit){
        viewModelScope.launch {
            val bean = mApi.search(keywords)
            when(bean){
                is ApiResult.Success -> onSuccess(bean.data.data)
                is ApiResult.Error -> onError(bean.errorMessage)
            }
        }
    }
}
